package com.example.wendao.model.entity;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import java.util.Arrays;
import java.util.Objects;

@Entity
public class Goods extends BaseObservable {

    @PrimaryKey(autoGenerate = true)    // 物品id(自增主键)
    private int goodId;

    private String goodName;

    private int goodPrice;

    private String goodInfo;

    @ColumnInfo(typeAffinity = ColumnInfo.BLOB) // 物品图片(blob)
    private byte[] goodPic;




    public int getGoodId() {
        return goodId;
    }

    public void setGoodId(int goodId) {
        this.goodId = goodId;
    }

    public String getGoodName() {
        return goodName;
    }

    public void setGoodName(String goodName) {
        this.goodName = goodName;
    }

    public int getGoodPrice() {
        return goodPrice;
    }

    public void setGoodPrice(int goodPrice) {
        this.goodPrice = goodPrice;
    }

    public String getGoodInfo() {
        return goodInfo;
    }

    public void setGoodInfo(String goodInfo) {
        this.goodInfo = goodInfo;
    }

    public byte[] getGoodPic() {
        return goodPic;
    }

    public void setGoodPic(byte[] goodPic) {
        this.goodPic = goodPic;
    }

    @Ignore
    public Goods(int goodId, String goodName, int goodPrice, String goodInfo, byte[] goodPic) {
        this.goodId = goodId;
        this.goodName = goodName;
        this.goodPrice = goodPrice;
        this.goodInfo = goodInfo;
        this.goodPic = goodPic;
    }

    public Goods(){}

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Goods goods = (Goods) o;
        return goodId == goods.goodId &&
                goodPrice == goods.goodPrice &&
                Objects.equals(goodName, goods.goodName) &&
                Objects.equals(goodInfo, goods.goodInfo) &&
                Arrays.equals(goodPic, goods.goodPic);
    }

}
